package com.xf.auth.controller;

import com.xf.auth.service.UserRemotePermissionService;
import com.xf.auth.service.UserService;
import com.xf.common.core.entity.system.UserRemotePermission;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户管理
 *
 * @author xufeng
 * @version 1.0
 * @date 2021/12/1
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;
    @Resource
    private UserRemotePermissionService userRemotePermissionService;
    /**
     * 注册用户
     * @param username
     * @param password
     * @return
     */
    @PostMapping("/register")
    public boolean register(@RequestParam("username") String username, @RequestParam("password") String password){
       return userService.register(username,password);
    }

    /**
     * 更新权限
     * @return
     */
    @PostMapping("/saveOrUpdate")
    public boolean saveOrUpdate(@RequestBody @Validated  UserRemotePermission userRemotePermission){
        return userRemotePermissionService.saveOrUpdate( userRemotePermission);
    }


}
